<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <button id="addButton">添加元素</button>
    <script>
      function debounce(func, wait) {
        let timeout;
        return function () {
          let context = this; // this
          console.log(this);
          let args = arguments; // event
          clearTimeout(timeout);
          timeout = setTimeout(function () {
            func.apply(context, args);
          }, wait);
        };
      }
      function kkx(val) {
        console.log("张飞", val);
      }
      const kkxth = debounce(kkx, 500);
      const addButton = document.getElementById("addButton");

      addButton.addEventListener("click", function () {
        kkxth("ccc");
        console.log(this);
      });
      console.log(2024-2012);
    </script>
  </body>
</html>
